<?php

class db{
    function __construct($url,$user,$pwd){
        try {
            
        $this->conn = new PDO($url,$user,$pwd);
        $this->conn->exec("SET NAMES UTF8");
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
    
    
    
    function query($sql){
       return $this->conn->query($sql);
    }
}

$db = new db("oci:dbname=http://localhost:1521;dbname=orcl",'scott','scott');
if($db){
   $sql = "select * from emp";
    $res = $db->query($sql);
    
    
    while($row = $res->fetch(PDO::FETCH_OBJ)){
        $rows[] = $row;
    }
    foreach ($rows as $r){
        echo $r->ENAME;
    }
echo count($rows).'<br/>';
  //  print_r($rows);
}else{
    echo "失败 ";
}
echo "======================<br/>";

phpinfo();